import { useState, useEffect } from 'react'
import styles from './index.module.less'
import { history } from 'umi'
import type { RoleType } from '../generate/interface'
import { fetchSystemInfo } from './api'

export const NoReportDataPage = () => {
    const queryParams = history.location.query as { type: RoleType }
    const roleType = queryParams.type

    const [platform, setPlatform] = useState<string>('马兰花创业培训教学管理服务平台')

    useEffect(() => {
        if (roleType === 'teacher') return
        const initSystemInfo = async () => {
            const { data } = await fetchSystemInfo()
            setPlatform(`${data.website}${data.website_subtitle}`)
        }
        initSystemInfo()
    }, [roleType])

    return (
        <div className={styles.page}>
            <div className={styles.text}>
                <p>2025年</p>

                <p className={styles.platform}>
                    {roleType === 'teacher' ? '马兰花创业培训教学管理服务平台' : platform}
                </p>

                <p>期待与您结伴同行</p>
            </div>

            <div className={styles.logo_sign} />

            <div className={styles.footer}>
                <p>*该报告为主管部门、培训机构、培训讲师年度报告</p>
                <p>统计周期截至2024年12月31日</p>
            </div>
        </div>
    )
}

export default NoReportDataPage
